<script setup lang="ts">
import { ref } from 'vue'
import PositionSimulator from './components/PositionSimulator.vue'
import KellyAnalyzer from './components/KellyAnalyzer.vue'

const currentTab = ref<'martingale' | 'kelly'>('martingale')
</script>

<template>
  <div class="app-container">
    <header class="header">
      <div class="header-content">
        <h1>仓位管理模拟器</h1>
      </div>
      <nav class="menu-bar">
        <button :class="{active: currentTab === 'martingale'}" @click="currentTab = 'martingale'">
          <span class="button-icon">📈</span>
          <span class="button-text">马丁/反马丁模拟器</span>
        </button>
        <button :class="{active: currentTab === 'kelly'}" @click="currentTab = 'kelly'">
          <span class="button-icon">🎯</span>
          <span class="button-text">凯利公式模拟器</span>
        </button>
      </nav>
    </header>

    <main class="main-content">
      <PositionSimulator v-if="currentTab === 'martingale'" />
      <KellyAnalyzer v-else />
    </main>
  </div>
</template>

<style scoped>
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.header h1 {
  font-size: 1.8rem;
  margin: 0 0 0.5rem 0;
  font-weight: 600;
}

.header p {
  font-size: 1rem;
  margin: 0;
  opacity: 0.9;
}

.menu-bar {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.5rem;
  border-radius: 10px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.menu-bar button {
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  flex: 1;
  min-width: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.button-icon {
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}

.button-text {
  transition: color 0.3s ease;
}

.menu-bar button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.menu-bar button:hover .button-icon {
  transform: scale(1.1);
}

.menu-bar button.active {
  background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
  color: #764ba2;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), inset 0 1px 3px rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
  border: 1px solid rgba(118, 75, 162, 0.2);
}

.menu-bar button.active .button-icon {
  transform: scale(1.15);
}

.menu-bar button.active .button-text {
  font-weight: 700;
}

.menu-bar button.active::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #fff;
}

.main-content {
  flex: 1;
  width: 100%;
  padding: 0;
  margin: 0;
}

/* 手机端优化 */
@media (max-width: 768px) {
  .header {
    padding: 0.8rem;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .header p {
    font-size: 0.9rem;
  }

  .menu-bar {
    gap: 0.3rem;
    padding: 0.3rem;
    margin-top: 0.8rem;
  }

  .menu-bar button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-width: 120px;
    gap: 0.3rem;
  }

  .button-text {
    font-size: 0.85rem;
  }

  .button-icon {
    font-size: 1.1rem;
  }

  .menu-bar button.active::before {
    border-left-width: 6px;
    border-right-width: 6px;
    border-bottom-width: 6px;
    bottom: -6px;
  }

  .main-content {
    padding: 0.5rem;
  }
}

/* 平板端 */
@media (min-width: 769px) and (max-width: 1024px) {
  .header h1 {
    font-size: 2rem;
  }

  .main-content {
    padding: 1.5rem;
  }
}

/* 宽屏电脑 */
@media (min-width: 1025px) {
  .header {
    padding: 2rem 1rem;
  }

  .header h1 {
    font-size: 2.5rem;
  }

  .header p {
    font-size: 1.2rem;
  }

  .main-content {
    padding: 2rem;
  }
}
</style>
